<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>11_过滤器</title>
</head>
<body>
<!--
对当前时间进行指定格式化显示
-->
<div id="example">
    <h2>显示格式化的日期时间</h2>
    <p>{{date}}</p>
    <p>完整{{date | dateString}}</p>
    <p>年月日{{date | dateString('YYYY-MM-DD')}}</p>
    <p>时分秒{{date | dateString('HH:mm:ss')}}</p>
</div>

<script type="text/javascript" src="../js/vue.js"></script>
<script type="text/javascript" src="https://cdn.bootcdn.net/ajax/libs/moment.js/2.29.1/moment.js"></script>
<script type="text/javascript">
    //自定义过滤器
    Vue.filter('dateString',function(value,format){
        return moment(value).format(format || 'YYYY-MM-DD HH:mm:ss')
    })

const vm =new Vue({
    el:'#example',
    data:{
        date: new Date()
    }
})

</script>


</body>
</html>